package com.lou.springboot.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
    没有起作用，不知道为何
 */
@Configuration
public class SpringBootWebMvcConfigurer implements WebMvcConfigurer {

    @Autowired
    private UploadConfig uploadConfig;

    public void addResourceHandlers(ResourceHandlerRegistry registry){
        // 添加策略，将上传的文件映射到 /upload_files/ 静态路径
        registry.addResourceHandler("/upload_files/**")
                .addResourceLocations("file:" + uploadConfig.getStaticAccessPath());
    }

}
